package com.six.marketing.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/payment")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @Autowired
    private JwtUtils jwtUtils;

    @PostMapping("/process")
    public ResponseEntity<String> processPayment(@RequestHeader("Authorization") String token,
                                                 @RequestParam String orderId,
                                                 @RequestParam String couponId) {
        // 验证支付安全性逻辑

        // 处理订单
        try {
            paymentService.processOrder(orderId, couponId);
            return ResponseEntity.ok("Payment processed successfully");
        } catch (Exception e) {
            return ResponseEntity.status(500).body("Payment processing failed: " + e.getMessage());
        }
    }
}

